<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:setBundle basename="messages.messages"/>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<link rel="stylesheet" href="/Epics/jslib/global.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><fmt:message key="siteName"/></title>
</head>

<script src="/Epics/jslib/jquery-1.9.1.js"></script>
<script src="/Epics/jslib/jquery.validate.min.js"></script>

<script type="text/javascript">
	$(document).ready(
			function() {
				
				$("#inputForm").validate({
					rules : {
						oldPassword: {
							required : true
						},
						newPassword: {
							required : true
						},
						passwordAgain : {
							required : true,
						}
					},
					messages : {
						password : {
							required : "Type your password."
						},
						newPassword: {
							required : "Type your password."
						},
						passwordAgain : {
							required : "Type your password."
						}
					}
				});
			
				
				$("#inputForm").submit(
						function() {
							if ($("input[name=password]").val() == $(
									"input[name=passwordAgain]").val()) {
								return true;
							}
							$("p[id=printMessage]").text(
									"Password mismatch.").show();
							return false;
						});
			});
</script>
<body>
	<%@ include file="../Template/TMainLine.jsp"%>
	<%@ include file="../Template/TMessage.jsp"%>
	
	<c:if test="${!empty user}">
	<form action="SChangePasswordOut" method="post" id="inputForm">
		<table>
			<tr>
				<td>Email:</td>
				<td>${user.email}</td>
			</tr>
			<tr>
				<td>Old password:</td>
				<td><input type="password" name="oldPassword" /></td>
			</tr>
			<tr>
				<td>New password:</td>
				<td><input type="password" name="newPassword" /></td>
			</tr>
			<tr>
				<td>Repeat password:</td>
				<td><input type="password" name="newPasswordAgain" /></td>
			</tr>
			<tr>
				<td colspan="2"><input type="submit" value="Save changes" /></td>
			</tr>
		</table>
	</form>
	</c:if>
</body>
</html>